package net.zisen.cloud.goods.ctrl;

import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.goods.model.Goods;
import net.zisen.cloud.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tim/278002989@qq.com
 * @Classname GoodsCtrl
 * @Description TODO
 * @Date 2019-05-17 17:25
 */
@RestController
public class GoodsCtrl {

    @Autowired
    private GoodsService service;

    @RequestMapping(value = "/goods/quality/{goodsId}")
    public ResultMsg updateQuality(@PathVariable Long goodsId, Integer quality) {
        return this.service.updateQuality(goodsId, quality);
    }

    @RequestMapping(value = "/goods/{goodsId}")
    public ResultMsg<Goods> goodsDetail(@PathVariable Long goodsId) {
        Goods goods = this.service.getById(goodsId);
        return ResultMsg.ok().data(goods);
    }
}
